<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

          <a-col :md="6" :sm="8">
            <a-form-item label="书名">
              <a-input placeholder="请输入书名" v-model="queryParam.bname"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="作者">
              <a-input placeholder="请输入作者" v-model="queryParam.author"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8" >
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
           <a @click="handleShow(record.id)">竞拍记录</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <auction-modal ref="modalForm" @ok="modalFormOk"></auction-modal>

    <auctionRecord-modal ref="edit" @ok="modalFormOk"></auctionRecord-modal>
  </a-card>
</template>

<script>
  import AuctionModal from './modules/AuctionModal'
  import AuctionRecordModal from './modules/AuctionRecordModal'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'

  export default {
    name: "AuctionList",
    mixins:[JeecgListMixin],
    components: {
      AuctionModal,
      AuctionRecordModal,
    },
    data () {
      return {
        description: '竞拍管理页面',
        // 表头
        columns: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
           },
		   {
            title: '书名',
            align:"center",
            dataIndex: 'bname'
           },
		   {
            title: '作者',
            align:"center",
            dataIndex: 'author'
           },
		  //  {
      //       title: '出版社',
      //       align:"center",
      //       dataIndex: 'press'
      //      },
		   {
            title: '出版时间',
            align:"center",
            dataIndex: 'publishTime'
           },
		  //  {
      //       title: '版次',
      //       align:"center",
      //       dataIndex: 'edition'
      //      },
		  //  {
      //       title: '页数',
      //       align:"center",
      //       dataIndex: 'pageNum'
      //      },
		  //  {
      //       title: '字数',
      //       align:"center",
      //       dataIndex: 'wordNum'
      //      },
		  //  {
      //       title: '印刷时间',
      //       align:"center",
      //       dataIndex: 'printTime'
      //      },
		  //  {
      //       title: '开本，字典，16k，32k，64k',
      //       align:"center",
      //       dataIndex: 'booksize'
      //      },
		  //  {
      //       title: '纸质，胶版纸',
      //       align:"center",
      //       dataIndex: 'page'
      //      },
		  //  {
      //       title: '所属分类',
      //       align:"center",
      //       dataIndex: 'cid'
      //      },
		  //  {
      //       title: '图片',
      //       align:"center",
      //       dataIndex: 'imgBig'
      //      },
		   {
            title: '开始时间',
            align:"center",
            dataIndex: 'start'
           },
		  //  {
      //       title: '开始时间戳',
      //       align:"center",
      //       dataIndex: 'startTimestamp'
      //      },
		   {
            title: '结束时间',
            align:"center",
            dataIndex: 'end'
           },
		  //  {
      //       title: '结束时间戳',
      //       align:"center",
      //       dataIndex: 'endTimestamp'
      //      },
		   {
            title: '起始价格',
            align:"center",
            dataIndex: 'startPrice'
           },
		   {
            title: '竞拍价格',
            align:"center",
            dataIndex: 'auctionPrice'
           },
		   {
            title: '竞拍者',
            align:"center",
            dataIndex: 'auctionName'
           },
		  //  {
      //       title: '竞拍者用户id',
      //       align:"center",
      //       dataIndex: 'uid'
      //      },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' },
          }
        ],
		url: {
          list: "/auction/auction/list",
          delete: "/auction/auction/delete",
          deleteBatch: "/auction/auction/deleteBatch",
          exportXlsUrl: "auction/auction/exportXls",
          importExcelUrl: "auction/auction/importExcel",
       },
    }
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
    methods: {
     handleShow:function(aid){
      //alert(aid)
      this.$refs.edit.edit(aid);
      this.$refs.edit.title = "竞拍记录";
      this.$refs.edit.disableSubmit = false;
     }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>